package demo2;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class EmployeeManager {
    private static List<Employee>employees=new ArrayList<>();
    static {
        employees.add(new Employee("1","王五",22,3200));
        employees.add(new Employee("2","李四",25,3500));
        employees.add(new Employee("1","王五",25,300));
    }
    public static void inter(String name,Employee exception){
        int index=-1;
        for (int i = 0; i <employees.size() ; i++) {
            if (employees.get(i).getName().equals(name)){
                index=i;
                break;
            }
        }
        if (index!=-1){
            employees.add(index,exception);
        }

    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public static void main(String[] args) {
        System.out.println("添加信息赵六");
        Employee employee=new Employee("4","赵六",24,3300);
        inter("李四",employee);
        for (int i = 0; i < employees.size() ; i++) {
            Employee employee1=employees.get(i);
            System.out.println(employee1.toString());
        }
        System.out.println("删除李四");
        employees.remove(2);
        for (int i = 0; i < employees.size() ; i++) {
            Employee employee1=employees.get(i);
            System.out.println(employee1.toString());
        }
        System.out.println("比较两个员工第一个和最后一个");
      boolean flag= employees.get(0).equals(employees.get(2));
        System.out.println(flag);


    }
}
